package com.sqly.doc.menu.gxy;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.pojo.GxyHzsf;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;

//import cn.pedant.SweetAlert.SweetAlertDialog;

/**
 * Created by Administrator on 2017/11/22 0022.
 */

public class gxy extends MyBaseActivity {
    EditText zz_qt, tz,tz1, tzzs, tzzs1, xl, tz_qt, fzjc, ywmc1, mc1, dw1, mr1, ywmc2, mc2, dw2, mr2, ywmc3, mr3, mc3, dw3, qtywmc, qtmr, qtmc, qtdw,
            ywblfy_qt, tzywmc1, tzmc1, tzdw1, tzmr1, tzywmc2, tzmc2, tzdw2, tzmr2, tzywmc3, tzmc3, tzdw3, tzmr3, tzqtywmc, tzqtmc, tzqtdw, tzqtmr;
    EditText  rxyl,rxyl2, ryjl, ryjl2, yd_ci, yd_ci2, yd_fz, yd_fz2;
    TextView sfrq;
    RadioGroup sffs, syqk, syqkxc, xltz, zyxw, fyycx, ywblfy, sffl, xbglcs;
    String sffss = "", syqks = "", syqks2 = "", xltzs = "", zyxws = "", fyycxs = "", ywblfys = "", sffls = "", xbglcss = "";
    MultiLineChooseLayout zz;//症状
    private List<String> zzdata = new ArrayList<>();
    private CustomDatePicker customDatePicker;
    Context con = gxy.this;
    //转诊
    EditText zzyy, zz_jgjkb, zz_lxr, zz_lxdh;
    RadioGroup sfzz,zzjg,gxyfc,gxyfj;
    String sfzzs="", zzjgs = "", gxyfcs = "", gxyfjs = "";
    TextView xcsfrq,xm;
    //标题
    TextView title, uname;
    EditText xy1, xy2;
    String JKDAH = "";
    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";
    GxyHzsf obj;
    String url = "";
    JuMin j;

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;
    LinearLayout back;

    @Override
    protected void initUI() {
        setContentView(R.layout.gxy);
        if (getIntent().getStringExtra("type").equals("edit")) {
            obj = (GxyHzsf) getIntent().getExtras().getSerializable("b");
            url = HttpUrl.EditGxyfsjl;
            init();

            try {
                Log.i("newStaticurl",Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()));
                if(!StringUtils.isEmpty(obj.getImg())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                    ImageLoader.getInstance().getDiscCache().clear();
                    ImageLoader.getInstance().clearMemoryCache();
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
                }
                if(!StringUtils.isEmpty(obj.getImg1())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                    ImageLoader.getInstance().getDiscCache().clear();
                    ImageLoader.getInstance().clearMemoryCache();
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
                }
                if(!StringUtils.isEmpty(obj.getImg2())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                    ImageLoader.getInstance().getDiscCache().clear();
                    ImageLoader.getInstance().clearMemoryCache();
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            xm.setClickable(false);
        } else {
            url = HttpUrl.AddGxyfsjl;
            obj = new GxyHzsf();
            init();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else if (requestCode == 1) {
            j = (JuMin) data.getExtras().getSerializable("j");
            getObject();
        }else if (requestCode == 8) {
            String record_id = (String) data.getExtras().getString("record_id");
            ysqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            sfysqm.setImageBitmap(bb);
            sfysqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if (requestCode == 9) {
            String record_id = (String) data.getExtras().getString("record_id");
            jmqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            brqm.setImageBitmap(bb);
            brqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if(requestCode == 119){
            String img_record_id = (String) data.getExtras().getString("img_record_id");
            pz_record_id.setText(img_record_id);
            pzChange = true;
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            xcqm.setImageBitmap(bb);
        }
    }


    public void init() {
        //姓名
        xm = (TextView) findViewById(R.id.XINGMING);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING())) {
            xm.setText(obj.getXINGMING());
        } else {
            xm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(null == obj.getSFFS() || StringUtils.isEmpty(obj.getSFFS())){
                        SweetAlertDialogUtil.WarningDialog(con, "提示", "请先选择随访方式");
                    }else {
                        startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "gxy.class").putExtra("sffs", obj.getSFFS()), 1);
                    }
                }
            });
        }
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "gxysf")
                        .putExtra("imageType", "img1")
                        .putExtra("class","gxy.class"), 8);
            }
        });
        //本人签名
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            Log.i("tppath",Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg");
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "gxysf")
                        .putExtra("imageType", "img")
                        .putExtra("class","gxy.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
//            //清空图片
//            xcqm.setWillNotDraw(true);
//            //设置图片
//            xcqm.setWillNotDraw(false);
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
//            xcqm.refreshDrawableState();
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        back = (LinearLayout)findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });
        title.setText("高血压患者随访记录");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //保存
                if(null == obj.getSFFS() || StringUtils.isEmpty(obj.getSFFS())) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "请先选择随访方式");
                }else if(null == xm.getText().toString() || "".equals(xm.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "姓名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                }else if(null == sfrq.getText().toString() || "".equals(sfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访日期不能为空");
                } else if(null == xcsfrq.getText().toString() || "".equals(xcsfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "下次随访日期不能为空");
                } else if("3".equals(obj.getSFFS()) && (null == xy1.getText().toString() || "".equals(xy1.getText().toString()) ||
                        null == xy2.getText().toString() || "".equals(xy2.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "血压值不能为空");
                }else if("3".equals(obj.getSFFS()) && (null == xl.getText().toString() || "".equals(xl.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "心率不能为空");
                } else if(("1".equals(obj.getSFFS()) || "2".equals(obj.getSFFS())) && (null == xy1.getText().toString() || "".equals(xy1.getText().toString()) ||
                        null == xy2.getText().toString() || "".equals(xy2.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "血压值不能为空,请点击“姓名”重新选择居民");
                } else {
                    if (obj == null)
                        obj = new GxyHzsf();
                    ArrayList<Integer> zzlist = zz.getAllItemSelectedIndex();
                    String zzs = "";
                    for (int i = 0; i < zzlist.size(); i++) {
                        if (i == 0)
                            zzs = (zzlist.get(i)+1) + "";
                        else
                            zzs = zzs + "," + (zzlist.get(i)+1);
                    }
                    obj.setZHENGZHUANG(zzs);
                    obj.setZZQT(zz_qt.getText().toString());
                    obj.setXUEYA1(xy1.getText().toString());
                    obj.setXUEYA2(xy2.getText().toString());
                    obj.setTIZHONG(tz.getText().toString());
                    obj.setTIZHONGXC(tz1.getText().toString());
                    obj.setBMI(tzzs.getText().toString());
                    obj.setBMIXC(tzzs1.getText().toString());
                    obj.setXINLV(xl.getText().toString());
                    obj.setTZQT(tz_qt.getText().toString());
                    obj.setRXYL(rxyl.getText().toString());
                    obj.setRXYLXC(rxyl2.getText().toString());
                    obj.setRYJL(ryjl.getText().toString());
                    obj.setRYJLXC(ryjl2.getText().toString());
                    obj.setYDCS(yd_ci.getText().toString());
                    obj.setYDCSXC(yd_ci2.getText().toString());
                    obj.setYDSC(yd_fz.getText().toString());
                    obj.setYDSCXC(yd_fz2.getText().toString());
                    obj.setFZJC(fzjc.getText().toString());
                    obj.setYWMC1(ywmc1.getText().toString());
                    obj.setYWYL1(mc1.getText().toString());
                    obj.setYWYF1(mr1.getText().toString());
                    obj.setYWDW1(dw1.getText().toString());

                    obj.setYWMC2(ywmc2.getText().toString());
                    obj.setYWYL2(mc2.getText().toString());
                    obj.setYWYF2(mr2.getText().toString());
                    obj.setYWDW2(dw2.getText().toString());

                    obj.setYWMC3(ywmc3.getText().toString());
                    obj.setYWYL3(mc3.getText().toString());
                    obj.setYWYF3(mr3.getText().toString());
                    obj.setYWDW3(dw3.getText().toString());

                    obj.setYWQTMC(qtywmc.getText().toString());
                    obj.setYWQTYL(qtmc.getText().toString());
                    obj.setYWQTYF(qtmr.getText().toString());
                    obj.setYWQTDW(qtdw.getText().toString());

                    obj.setYWBLFYY(ywblfy_qt.getText().toString());

                    obj.setTZYWMC1(tzywmc1.getText().toString());
                    obj.setTZYWYL1(tzmc1.getText().toString());
                    obj.setTZYWYF1(tzmr1.getText().toString());
                    obj.setTZYWDW1(tzdw1.getText().toString());

                    obj.setTZYWMC2(tzywmc2.getText().toString());
                    obj.setTZYWYL2(tzmc2.getText().toString());
                    obj.setTZYWYF2(tzmr2.getText().toString());
                    obj.setTZYWDW2(tzdw2.getText().toString());

                    obj.setSFRQ(sfrq.getText().toString());
                    obj.setTZYWMC3(tzywmc3.getText().toString());
                    obj.setTZYWYL3(tzmc3.getText().toString());
                    obj.setTZYWYF3(tzmr3.getText().toString());
                    obj.setTZYWDW3(tzdw3.getText().toString());

                    obj.setTZYWQTMC(tzqtywmc.getText().toString());
                    obj.setTZYWQTYL(tzqtmc.getText().toString());
                    obj.setTZYWQTYF(tzqtmr.getText().toString());
                    obj.setTZYWQTDW(tzqtdw.getText().toString());

                    obj.setZZJGJKB(zz_jgjkb.getText().toString());
                    obj.setZZLXFS(zz_lxdh.getText().toString());
                    obj.setZZYY(zzyy.getText().toString());
                    obj.setZZLXR(zz_lxr.getText().toString());

                    obj.setXCSFRQ(xcsfrq.getText().toString());
                    if (NetWorkUtils.isNetworkConnected(con)) {
                        RequestParams ps = new RequestParams();
                        ps.add("entity.SFRQ", obj.getSFRQ());
                        ps.add("entity.ZHENGZHUANG", obj.getZHENGZHUANG());
                        ps.add("entity.ZZQT", obj.getZZQT());
                        ps.add("entity.XUEYA1", obj.getXUEYA1());
                        ps.add("entity.XUEYA2", obj.getXUEYA2());
                        ps.add("entity.TIZHONG", obj.getTIZHONG());
                        ps.add("entity.TIZHONGXC", obj.getTIZHONGXC());
                        ps.add("entity.BMI", obj.getBMI());
                        ps.add("entity.BMIXC", obj.getBMIXC());
                        ps.add("entity.XINLV", obj.getXINLV());
                        ps.add("entity.TZQT", obj.getTZQT());
                        ps.add("entity.RXYL", obj.getRXYL());
                        ps.add("entity.RXYLXC", obj.getRXYLXC());
                        ps.add("entity.RYJL", obj.getRYJL());
                        ps.add("entity.RYJLXC", obj.getRYJLXC());
                        ps.add("entity.YDCS", obj.getYDCS());
                        ps.add("entity.YDCSXC", obj.getYDCSXC());
                        ps.add("entity.YDSC", obj.getYDSC());
                        ps.add("entity.YDSCXC", obj.getYDSCXC());
                        ps.add("entity.SYQK", obj.getSYQK());
                        ps.add("entity.SYQKXC", obj.getSYQKXC());
                        ps.add("entity.XLTZ", obj.getXLTZ());
                        ps.add("entity.ZYXW", obj.getZYXW());
                        ps.add("entity.FZJC", obj.getFZJC());
                        ps.add("entity.YWMC1", obj.getYWMC1());
                        ps.add("entity.YWYL1", obj.getYWYL1());
                        ps.add("entity.YWYF1", obj.getYWYF1());
                        ps.add("entity.YWDW1", obj.getYWDW1());

                        ps.add("entity.YWMC2", obj.getYWMC2());
                        ps.add("entity.YWYL2", obj.getYWYL2());
                        ps.add("entity.YWYF2", obj.getYWYF2());
                        ps.add("entity.YWDW2", obj.getYWDW2());

                        ps.add("entity.YWMC3", obj.getYWMC3());
                        ps.add("entity.YWYL3", obj.getYWYL3());
                        ps.add("entity.YWYF3", obj.getYWYF3());
                        ps.add("entity.YWDW3", obj.getYWDW3());

                        ps.add("entity.YWQTMC", obj.getYWQTMC());
                        ps.add("entity.YWQTYL", obj.getYWQTYL());
                        ps.add("entity.YWQTYF", obj.getYWQTYF());
                        ps.add("entity.YWQTDW", obj.getYWQTDW());

                        ps.add("entity.FYYCX", obj.getFYYCX());
                        ps.add("entity.YWBLFY", obj.getYWBLFY());
                        ps.add("entity.YWBLFYY", obj.getYWBLFYY());
                        ps.add("entity.SFFL", obj.getSFFL());
                        ps.add("entity.XYBGLCS", obj.getXYBGLCS());

                        ps.add("entity.TZYWMC1", obj.getTZYWMC1());
                        ps.add("entity.TZYWYL1", obj.getTZYWYL1());
                        ps.add("entity.TZYWYF1", obj.getTZYWYF1());
                        ps.add("entity.TZYWDW1", obj.getTZYWDW1());

                        ps.add("entity.TZYWMC2", obj.getTZYWMC2());
                        ps.add("entity.TZYWYL2", obj.getTZYWYL2());
                        ps.add("entity.TZYWYF2", obj.getTZYWYF2());
                        ps.add("entity.TZYWDW2", obj.getTZYWDW2());

                        ps.add("entity.SFFS",obj.getSFFS());
                        ps.add("entity.TZYWMC3", obj.getTZYWMC3());
                        ps.add("entity.TZYWYL3", obj.getTZYWYL3());
                        ps.add("entity.TZYWYF3", obj.getTZYWYF3());
                        ps.add("entity.TZYWDW3", obj.getTZYWDW3());

                        ps.add("entity.TZYWQTMC", obj.getTZYWQTMC());
                        ps.add("entity.TZYWQTYL", obj.getTZYWQTYL());
                        ps.add("entity.TZYWQTYF", obj.getTZYWQTYF());
                        ps.add("entity.TZYWQTDW", obj.getTZYWQTDW());


                        ps.add("entity.SFZZ", obj.getSFZZ());
                        ps.add("entity.ZZYY", obj.getZZYY());
                        ps.add("entity.ZZJG", obj.getZZJG());
                        ps.add("entity.GXYFC", obj.getGXYFC());
                        if (getIntent().getStringExtra("type").equals("edit"))
                            ps.add("entity.SFJLH", obj.getSFJLH());
                        else
                            ps.add("entity.JKDAH", JKDAH);
                        ps.add("entity.ZZLXR", obj.getZZLXR());
                        ps.add("entity.ZZLXFS", obj.getZZLXFS());
                        ps.add("entity.ZZJGJKB", obj.getZZJGJKB());
                        ps.add("entity.XCSFRQ", obj.getXCSFRQ());
                        ps.add("entity.XINGMING", obj.getXINGMING());
                        ps.add("entity.CARDNUM", obj.getCARDNUM());
                        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                        ps.add("type", "2");

                        ps.add("pz_record_id", pz_record_id.getText().toString());
                        ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                        //gxy.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                        UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                            @Override
                            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                                String content = new String(response);
                                Log.i("高血压",content);
                                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                                if (ret.getCode().equals("200")) {
                                    MyToastUtil.ShowToast(con, "成功");
                                }else{
                                    MyToastUtil.ShowToast(con, ret.getInfo());
                                }
                                finish();
                            }

                            @Override
                            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                                MyToastUtil.ShowToast(con, "失败");
                            }
                        });
                    }
                }
            }
        });
        zz_qt = (EditText) findViewById(R.id.zz_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getZZQT())) {
            zz_qt.setText(obj.getZZQT());
        }
        xy1 = (EditText) findViewById(R.id.xy1);
        gxyfj = (RadioGroup) findViewById(R.id.gxyfj);
        xy1.addTextChangedListener(new GxyfjChangeListener());
        xy2 = (EditText) findViewById(R.id.xy2);
        xy2.addTextChangedListener(new GxyfjChangeListener());
        xl = (EditText) findViewById(R.id.xl);
        if("1".equals(SharedPreferencesUtils.getParam(con, "gxycj", "0").toString())){
            xy1.setEnabled(false);
            xy2.setEnabled(false);
            xl.setEnabled(false);
        }else{
            xy1.setEnabled(true);
            xy2.setEnabled(true);
            xl.setEnabled(true);
        }
        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA1())) {
            xy1.setText(obj.getXUEYA1());
        }
        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA2())) {
            xy2.setText(obj.getXUEYA2());
        }
//        gxyfj = (TextView) findViewById(R.id.gxyfj);
//        if(null != xy1.getText().toString() && !"".equals(xy1.getText().toString()) && null != xy2.getText().toString() && !"".equals(xy2.getText().toString())){
//            Integer gy = Integer.parseInt(xy1.getText().toString()), dy = Integer.parseInt(xy2.getText().toString());
//            //收缩压在140mmHg-159mmHg，舒张压在90mmHg-99mmHg，为一级高血压。
//            // 收缩压在160mmHg-179mmHg，舒张压在100mmHg-109mmHg，为二级高血压。
//            // 收缩压≥180mmHg，舒张压≥110mmHg，为三级高血压。
//            if(gy>=140 && gy<=159 && dy>=90 && dy<=99){
//                gxyfj.setText("1级高血压");
//            }else if(gy>=160 && gy<=179 && dy>=100 && dy<=109){
//                gxyfj.setText("2级高血压");
//            }else if(gy>=180 && dy>=101){
//                gxyfj.setText("3级高血压");
//            }else{
//                gxyfj.setText("正常高值");
//            }
//        }

        tz = (EditText) findViewById(R.id.tz);
        if (obj != null && !StringUtils.isEmpty(obj.getTIZHONG())) {
            tz.setText(obj.getTIZHONG());
        }
        tz1 = (EditText) findViewById(R.id.tz1);
        if (obj != null && !StringUtils.isEmpty(obj.getTIZHONGXC())) {
            tz1.setText(obj.getTIZHONGXC());
        }
        tzzs = (EditText) findViewById(R.id.tzzs);
        if (obj != null && !StringUtils.isEmpty(obj.getBMI())) {
            tzzs.setText(obj.getBMI());
        }
        tzzs1 = (EditText) findViewById(R.id.tzzs1);
        if (obj != null && !StringUtils.isEmpty(obj.getBMIXC())) {
            tzzs1.setText(obj.getBMIXC());
        }

        if (obj != null && !StringUtils.isEmpty(obj.getXINLV())) {
            xl.setText(obj.getXINLV());
        }
        tz_qt = (EditText) findViewById(R.id.tz_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getTZQT())) {
            tz_qt.setText(obj.getTZQT());
        }
        rxyl = (EditText) findViewById(R.id.rxyl);
        if (obj != null && !StringUtils.isEmpty(obj.getRXYL())) {
            rxyl.setText(obj.getRXYL());
        }
        rxyl2 = (EditText) findViewById(R.id.rxyl2);
        if (obj != null && !StringUtils.isEmpty(obj.getRXYLXC())) {
            rxyl2.setText(obj.getRXYLXC());
        }
        ryjl = (EditText) findViewById(R.id.ryjl);
        if (obj != null && !StringUtils.isEmpty(obj.getRYJL())) {
            ryjl.setText(obj.getRYJL());
        }
        ryjl2 = (EditText) findViewById(R.id.ryjl2);
        if (obj != null && !StringUtils.isEmpty(obj.getRYJLXC())) {
            ryjl2.setText(obj.getRYJLXC());
        }
        yd_ci = (EditText) findViewById(R.id.yd_ci);
        if (obj != null && !StringUtils.isEmpty(obj.getYDCS())) {
            yd_ci.setText(obj.getYDCS());
        }
        yd_ci2 = (EditText) findViewById(R.id.yd_ci2);
        if (obj != null && !StringUtils.isEmpty(obj.getYDCSXC())) {
            yd_ci2.setText(obj.getYDCSXC());
        }
        yd_fz = (EditText) findViewById(R.id.yd_fz);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSC())) {
            yd_fz.setText(obj.getYDSC());
        }
        yd_fz2 = (EditText) findViewById(R.id.yd_fz2);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSCXC())) {
            yd_fz2.setText(obj.getYDSCXC());
        }
        fzjc = (EditText) findViewById(R.id.fzjc);
        if (obj != null && !StringUtils.isEmpty(obj.getFZJC())) {
            fzjc.setText(obj.getFZJC());
        }
        ywmc1 = (EditText) findViewById(R.id.ywmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC1())) {
            ywmc1.setText(obj.getYWMC1());
        }
        mc1 = (EditText) findViewById(R.id.mc1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYL1())) {
            mc1.setText(obj.getYWYL1());
        }
        dw1 = (EditText) findViewById(R.id.dw1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW1())) {
            dw1.setText(obj.getYWDW1());
        }
        mr1 = (EditText) findViewById(R.id.mr1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF1())) {
            mr1.setText(obj.getYWYF1());
        }

        ywmc2 = (EditText) findViewById(R.id.ywmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC2())) {
            ywmc2.setText(obj.getYWMC2());
        }
        mc2 = (EditText) findViewById(R.id.mc2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYL2())) {
            mc2.setText(obj.getYWYL2());
        }
        dw2 = (EditText) findViewById(R.id.dw2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW2())) {
            dw2.setText(obj.getYWDW2());
        }
        mr2 = (EditText) findViewById(R.id.mr2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF2())) {
            mr2.setText(obj.getYWYF2());
        }

        ywmc3 = (EditText) findViewById(R.id.ywmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC3())) {
            ywmc3.setText(obj.getYWMC3());
        }
        mc3 = (EditText) findViewById(R.id.mc3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYL3())) {
            mc3.setText(obj.getYWYL3());
        }
        dw3 = (EditText) findViewById(R.id.dw3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW3())) {
            dw3.setText(obj.getYWDW3());
        }
        mr3 = (EditText) findViewById(R.id.mr3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF3())) {
            mr3.setText(obj.getYWYF3());
        }


        qtywmc = (EditText) findViewById(R.id.qtywmc);
        if (obj != null && !StringUtils.isEmpty(obj.getYWQTMC())) {
            qtywmc.setText(obj.getYWQTMC());
        }
        qtmc = (EditText) findViewById(R.id.qtmc);
        if (obj != null && !StringUtils.isEmpty(obj.getYWQTYL())) {
            qtmc.setText(obj.getYWQTYL());
        }
        qtdw = (EditText) findViewById(R.id.qtdw);
        if (obj != null && !StringUtils.isEmpty(obj.getYWQTDW())) {
            qtdw.setText(obj.getYWQTDW());
        }
        qtmr = (EditText) findViewById(R.id.qtmr);
        if (obj != null && !StringUtils.isEmpty(obj.getYWQTYF())) {
            qtmr.setText(obj.getYWQTYF());
        }

        ywblfy_qt = (EditText) findViewById(R.id.ywblfy_wu_des);
        if (obj != null && !StringUtils.isEmpty(obj.getYWBLFYY())) {
            ywblfy_qt.setText(obj.getYWBLFYY());
        }
        tzywmc1 = (EditText) findViewById(R.id.tzywmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC1())) {
            tzywmc1.setText(obj.getTZYWMC1());
        }
        tzmc1 = (EditText) findViewById(R.id.tzmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL1())) {
            tzmc1.setText(obj.getTZYWYL1());
        }
        tzmr1 = (EditText) findViewById(R.id.tzmr1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF1())) {
            tzmr1.setText(obj.getTZYWYF1());
        }
        tzdw1 = (EditText) findViewById(R.id.tzdw1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW1())) {
            tzdw1.setText(obj.getTZYWDW1());
        }

        tzywmc2 = (EditText) findViewById(R.id.tzywmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC2())) {
            tzywmc2.setText(obj.getTZYWMC2());
        }
        tzmc2 = (EditText) findViewById(R.id.tzmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL2())) {
            tzmc2.setText(obj.getTZYWYL2());
        }
        tzmr2 = (EditText) findViewById(R.id.tzmr2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF2())) {
            tzmr2.setText(obj.getTZYWYF2());
        }
        tzdw2 = (EditText) findViewById(R.id.tzdw2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW2())) {
            tzdw2.setText(obj.getTZYWDW2());
        }

        tzywmc3 = (EditText) findViewById(R.id.tzywmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC3())) {
            tzywmc3.setText(obj.getTZYWMC3());
        }
        tzmc3 = (EditText) findViewById(R.id.tzmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL3())) {
            tzmc3.setText(obj.getTZYWYL3());
        }
        tzmr3 = (EditText) findViewById(R.id.tzmr3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF3())) {
            tzmr3.setText(obj.getTZYWYF3());
        }
        tzdw3 = (EditText) findViewById(R.id.tzdw3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW3())) {
            tzdw3.setText(obj.getTZYWDW3());
        }

        tzqtywmc = (EditText) findViewById(R.id.tzqtywmc);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWQTMC())) {
            tzqtywmc.setText(obj.getTZYWQTMC());
        }
        tzqtmc = (EditText) findViewById(R.id.tzqtmc);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWQTYL())) {
            tzqtmc.setText(obj.getTZYWQTYL());
        }
        tzqtmr = (EditText) findViewById(R.id.tzqtmr);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWQTYF())) {
            tzqtmr.setText(obj.getTZYWQTYF());
        }
        tzqtdw = (EditText) findViewById(R.id.tzqtdw);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWQTDW())) {
            tzqtdw.setText(obj.getTZYWQTDW());
        }

        zzyy = (EditText) findViewById(R.id.zz_yy);
        if (obj != null && !StringUtils.isEmpty(obj.getZZYY())) {
            zzyy.setText(obj.getZZYY());
        }
        zz_jgjkb = (EditText) findViewById(R.id.jgjkb);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJGJKB())) {
            zz_jgjkb.setText(obj.getZZJGJKB());
        }
        zz_lxr = (EditText) findViewById(R.id.zz_lxr);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXR())) {
            zz_lxr.setText(obj.getZZLXR());
        }
        zz_lxdh = (EditText) findViewById(R.id.zz_lxdh);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXFS())) {
            zz_lxdh.setText(obj.getZZLXFS());
        }

        sfrq = (TextView) findViewById(R.id.sfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getSFRQ())) {
            sfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        sfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sfrq.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });

        xcsfrq = (TextView) findViewById(R.id.xcsfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getXCSFRQ())) {
            xcsfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getXCSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        xcsfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String sfrqtemp = sfrq.getText().toString();
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        xcsfrq.setText(time.split(" ")[0]);
                    }
                }, sfrqtemp==null || "".equals(sfrqtemp) ? DateConvert.getCustomDatePickerStartRq() : sdf.format(DateConvert.toDate(sfrqtemp, "yyyy-MM-dd HH:mm")), DateConvert.getCustomDatePickerEndRq()); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(sfrqtemp==null || "".equals(sfrqtemp) ? DateConvert.getCustomDatePickerStartRq() : sdf.format(DateConvert.toDate(sfrqtemp, "yyyy-MM-dd HH:mm")));
            }
        });

        syqk = (RadioGroup) findViewById(R.id.syqk);
        if (obj != null && !StringUtils.isEmpty(obj.getSYQK())) {
            switch (Integer.parseInt(obj.getSYQK())) {
                case 1:
                    syqk.check(R.id.syqk1);
                    break;
                case 2:
                    syqk.check(R.id.syqk2);
                    break;
                case 3:
                    syqk.check(R.id.syqk3);
                    break;

            }
        }
        syqk.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.syqk1)
                    syqks = "1";
                if (i == R.id.syqk2)
                    syqks = "2";
                if (i == R.id.syqk3)
                    syqks = "3";
                obj.setSYQK(syqks);

            }
        });

        syqkxc = (RadioGroup) findViewById(R.id.syqkxc);
        if (obj != null && !StringUtils.isEmpty(obj.getSYQKXC())) {
            switch (Integer.parseInt(obj.getSYQKXC())) {
                case 1:
                    syqkxc.check(R.id.syqk12);
                    break;
                case 2:
                    syqkxc.check(R.id.syqk22);
                    break;
                case 3:
                    syqkxc.check(R.id.syqk32);
                    break;

            }
        }
        syqkxc.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.syqk12)
                    syqks2 = "1";
                if (i == R.id.syqk22)
                    syqks2 = "2";
                if (i == R.id.syqk32)
                    syqks2 = "3";
                obj.setSYQKXC(syqks2);
            }
        });

        xltz = (RadioGroup) findViewById(R.id.xltz);
        if (obj != null && !StringUtils.isEmpty(obj.getXLTZ())) {
            switch (Integer.parseInt(obj.getXLTZ())) {
                case 1:
                    xltz.check(R.id.xltz_lh);
                    break;
                case 2:
                    xltz.check(R.id.xltz_yb);
                    break;
                case 3:
                    xltz.check(R.id.xltz_c);
                    break;

            }
        }
        xltz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xltz_lh)
                    xltzs = "1";
                if (i == R.id.xltz_yb)
                    xltzs = "2";
                if (i == R.id.xltz_c)
                    xltzs = "3";
                obj.setXLTZ(xltzs);
            }
        });
        zyxw = (RadioGroup) findViewById(R.id.zyxw);
        if (obj != null && !StringUtils.isEmpty(obj.getXLTZ())) {
            switch (Integer.parseInt(obj.getXLTZ())) {
                case 1:
                    zyxw.check(R.id.zyxw_lh);
                    break;
                case 2:
                    zyxw.check(R.id.zyxw_yb);
                    break;
                case 3:
                    zyxw.check(R.id.zyxw_c);
                    break;

            }
        }
        zyxw.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.zyxw_lh)
                    zyxws = "1";
                if (i == R.id.zyxw_yb)
                    zyxws = "2";
                if (i == R.id.zyxw_c)
                    zyxws = "3";
                obj.setZYXW(zyxws);

            }
        });
        fyycx = (RadioGroup) findViewById(R.id.fyycx);
        if (obj != null && !StringUtils.isEmpty(obj.getFYYCX())) {
            switch (Integer.parseInt(obj.getFYYCX())) {
                case 1:
                    fyycx.check(R.id.fyycx_l);
                    break;
                case 2:
                    fyycx.check(R.id.fyycx_jd);
                    break;
                case 3:
                    fyycx.check(R.id.fyycx_bfy);
                    break;

            }
        }
        fyycx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.fyycx_l)
                    fyycxs = "1";
                if (i == R.id.fyycx_jd)
                    fyycxs = "2";
                if (i == R.id.fyycx_bfy)
                    fyycxs = "3";
                obj.setFYYCX(fyycxs);
            }
        });
        ywblfy = (RadioGroup) findViewById(R.id.ywblfy);
        if (obj != null && !StringUtils.isEmpty(obj.getYWBLFY())) {
            switch (Integer.parseInt(obj.getYWBLFY())) {
                case 1:
                    ywblfy.check(R.id.ywblfy_wu);
                    break;
                case 2:
                    ywblfy.check(R.id.ywblfy_you);
                    break;
            }
        }
        ywblfy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.ywblfy_wu) {
                    ywblfys = "1";
                    ywblfy_qt.setEnabled(false);
                } else {
                    ywblfy_qt.setEnabled(true);
                    ywblfys = "2";
                }
                obj.setYWBLFY(ywblfys);
            }
        });
        sffs = (RadioGroup) findViewById(R.id.sffs);
        if (obj != null && !StringUtils.isEmpty(obj.getSFFS())) {
            switch (Integer.parseInt(obj.getSFFS())) {
                case 1:
                    sffs.check(R.id.sffs_mz);
                    break;
                case 2:
                    sffs.check(R.id.sffs_jt);
                    break;
                case 3:
                    sffs.check(R.id.sffs_dh);
                    break;
            }
        }
        sffs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.sffs_mz) {
                    sffss = "1";
                    if(getIntent().getStringExtra("type").equals("edit")){
//                        xy1.setText("");
//                        xy2.setText("");
//                        xl.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        xl.setEnabled(false);
                    }else {
                        xy1.setText("");
                        xy2.setText("");
                        xl.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        xl.setEnabled(false);
                    }
                }
                if (i == R.id.sffs_jt) {
                    sffss = "2";
                    if(getIntent().getStringExtra("type").equals("edit") ){
//                        xy1.setText("");
//                        xy2.setText("");
//                        xl.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        xl.setEnabled(false);
                    }else {
                        xy1.setText("");
                        xy2.setText("");
                        xl.setText("");
                    }
                }
                if (i == R.id.sffs_dh) {//电话
                    sffss = "3";
                    xy1.setEnabled(true);
                    xy2.setEnabled(true);
                    xl.setEnabled(true);
                    xy1.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                    xy2.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                    xl.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                }
                obj.setSFFS(sffss);
            }
        });

        zz = (MultiLineChooseLayout) findViewById(R.id.zhengzhuang);
        zzdata.add("无症状");
        zzdata.add("头痛头晕");
        zzdata.add("恶心呕吐");
        zzdata.add("眼花耳鸣");
        zzdata.add("呼吸困难");
        zzdata.add("心悸胸闷");
        zzdata.add("鼻衄出血不止");
        zzdata.add("四肢发麻");
        zzdata.add("下肢水肿");
        zzdata.add("其他");
        zz.setList(zzdata);
        if (obj != null && !StringUtils.isEmpty(obj.getZHENGZHUANG())) {
            if (obj.getZHENGZHUANG().contains(",")) {
                String[] ss = obj.getZHENGZHUANG().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(Integer.parseInt(ss[i])==0){
                            zz.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else{
                            zz.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(Integer.parseInt(obj.getZHENGZHUANG())==0){
                    zz.setIndexItemSelected(Integer.parseInt(obj.getZHENGZHUANG()));
                }else{
                    zz.setIndexItemSelected(Integer.parseInt(obj.getZHENGZHUANG())-1);
                }

            }
        }
        //是否需要转诊
        sfzz = (RadioGroup) findViewById(R.id.sfzz);
        sfzz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.sfzz_xu)
                    sfzzs = "2";
                if (i == R.id.sfzz_bu)
                    sfzzs = "1";
                obj.setSFZZ(sfzzs);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getSFZZ())) {
            switch (Integer.parseInt(obj.getSFZZ())) {
                case 1:
                    sfzz.check(R.id.sfzz_bu);
                    break;
                case 2:
                    sfzz.check(R.id.sfzz_xu);
                    break;
            }
        }else{
            //sfzz.check(R.id.sfzz_bu);
        }
        //转诊结果
        zzjg = (RadioGroup) findViewById(R.id.zzjieguo);
        zzjg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.zzjieguo_dw)
                    zzjgs = "1";
                if (i == R.id.zzjieguo_wdw)
                    zzjgs = "2";
                obj.setZZJG(zzjgs);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            switch (Integer.parseInt(obj.getZZJG())) {
                case 1:
                    zzjg.check(R.id.zzjieguo_dw);
                    break;
                case 2:
                    zzjg.check(R.id.zzjieguo_wdw);
                    break;
            }
        }
        //高血压分层
        gxyfc = (RadioGroup) findViewById(R.id.gxyfc);
        gxyfc.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.gxyfc1)
                    gxyfcs = "1";
                if (i == R.id.gxyfc2)
                    gxyfcs = "2";
                if (i == R.id.gxyfc3)
                    gxyfcs = "3";
                if (i == R.id.gxyfc4)
                    gxyfcs = "4";
                obj.setGXYFC(gxyfcs);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getGXYFC())) {
            switch (Integer.parseInt(obj.getGXYFC())) {
                case 1:
                    gxyfc.check(R.id.gxyfc1);
                    break;
                case 2:
                    gxyfc.check(R.id.gxyfc2);
                    break;
                case 3:
                    gxyfc.check(R.id.gxyfc3);
                    break;
                case 4:
                    gxyfc.check(R.id.gxyfc4);
                    break;
            }
        }

        //高血压分级
        gxyfj.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.gxyfj1)
                    gxyfjs = "1";
                if (i == R.id.gxyfj2)
                    gxyfjs = "2";
                if (i == R.id.gxyfj3)
                    gxyfjs = "3";
                if (i == R.id.gxyfj4)
                    gxyfjs = "4";
                if (i == R.id.gxyfj5)
                    gxyfjs = "5";
                if (i == R.id.gxyfj6)
                    gxyfjs = "6";
                obj.setGXYFJ(gxyfjs);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getGXYFJ())) {
            switch (Integer.parseInt(obj.getGXYFJ())) {
                case 1:
                    gxyfj.check(R.id.gxyfj1);
                    break;
                case 2:
                    gxyfj.check(R.id.gxyfj2);
                    break;
                case 3:
                    gxyfj.check(R.id.gxyfj3);
                    break;
                case 4:
                    gxyfj.check(R.id.gxyfj4);
                    break;
                case 5:
                    gxyfj.check(R.id.gxyfj5);
                    break;
                case 6:
                    gxyfj.check(R.id.gxyfj6);
                    break;
            }
        }
        //随访分类
        sffl= (RadioGroup) findViewById(R.id.ccsffl);
        sffl.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.ccsffl_my)
                    sffls = "1";
                if (i == R.id.ccsffl_bmy)
                    sffls = "2";
                if (i == R.id.ccsffl_blfy)
                    sffls = "3";
                if (i == R.id.ccsffl_bfz)
                    sffls = "4";
                obj.setSFFL(sffls);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getSFFL())) {
            switch (Integer.parseInt(obj.getSFFL())) {
                case 1:
                    sffl.check(R.id.ccsffl_my);
                    break;
                case 2:
                    sffl.check(R.id.ccsffl_bmy);
                    break;
                case 3:
                    sffl.check(R.id.ccsffl_blfy);
                    break;
                case 4:
                    sffl.check(R.id.ccsffl_bfz);
                    break;
            }
        }
        //下一步管理措施
        xbglcs= (RadioGroup) findViewById(R.id.xbglcs);
        xbglcs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.xbglcs_cgsf)
                    xbglcss = "1";
                if (i == R.id.xbglcs_dycbmy)
                    xbglcss = "2";
                if (i == R.id.xbglcs_liangci)
                    xbglcss = "3";
                if (i == R.id.xbglcs_jjzz)
                    xbglcss = "4";
                obj.setXYBGLCS(xbglcss);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getXYBGLCS())) {
            switch (Integer.parseInt(obj.getXYBGLCS())) {
                case 1:
                    xbglcs.check(R.id.xbglcs_cgsf);
                    break;
                case 2:
                    xbglcs.check(R.id.xbglcs_dycbmy);
                    break;
                case 3:
                    xbglcs.check(R.id.xbglcs_liangci);
                    break;
                case 4:
                    xbglcs.check(R.id.xbglcs_jjzz);
                    break;
            }
        }
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }


    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        ps.add("sfrq", sfrq.getText().toString());
        ps.add("sffs", obj.getSFFS());

        UserClient.get(HttpUrl.GetGxyfsjlGrjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                Log.i("ycf2", content);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    if (StringUtils.isEmpty(ret.getOtherParams())) {//other是空的
                        JSONObject j = JSON.parseObject(ret.getRd());
                        obj = new GxyHzsf();
                        obj.setJKDAH(j.getString("JKDAH"));
                        obj.setXINGMING(j.getString("XINGMING"));
                        obj.setCARDNUM(j.getString("CARDNUM"));
                        obj.setSFFS(sffss);
                        JKDAH = j.getString("JKDAH");
                        xm.setText(j.getString("XINGMING"));
                        xy1.setText(j.getString("XY1"));
                        xy2.setText(j.getString("XY2"));
                        if(null != j.getString("XY1") && !"".equals(j.getString("XY1")) && null != j.getString("XY2") && !"".equals(j.getString("XY2"))){
//                            Integer gy = Integer.parseInt(j.getString("XY1") ), dy = Integer.parseInt(j.getString("XY2") );
//                            //收缩压在140mmHg-159mmHg，舒张压在90mmHg-99mmHg，为一级高血压。
//                            // 收缩压在160mmHg-179mmHg，舒张压在100mmHg-109mmHg，为二级高血压。
//                            // 收缩压≥180mmHg，舒张压≥110mmHg，为三级高血压。
//                            if(gy>=140 && gy<=159 && dy>=90 && dy<=99){
//                                gxyfj.setText("1级高血压");
//                            }else if(gy>=160 && gy<=179 && dy>=100 && dy<=109){
//                                gxyfj.setText("2级高血压");
//                            }else if(gy>=180 && dy>=101){
//                                gxyfj.setText("3级高血压");
//                            }else{
//                                gxyfj.setText("正常高值");
//                            }
                            Integer ssy = Integer.parseInt(j.getString("XY1") ),
                                    szy = Integer.parseInt(j.getString("XY2") );
                            int fj = 1;
                            if(ssy>=180 || szy>=110){
                                fj = 6;
                            }else if((ssy>=160 && ssy<=179) || (szy>=100 && szy<=109)){
                                fj =5;
                            }else if((ssy>=140 && ssy<=159) || (szy>=90 && szy<=99)){
                                fj =4;
                            }else if(ssy>=140 && szy<90){
                                fj = 3;
                            }else if((ssy>=120 && ssy<=139) || (szy>=80 && szy<=89)){
                                fj =2;
                            }else if(ssy<120 && szy<80){
                                fj = 1;
                            }
                            switch (fj) {
                                case 1:
                                    gxyfj.check(R.id.gxyfj1);
                                    break;
                                case 2:
                                    gxyfj.check(R.id.gxyfj2);
                                    break;
                                case 3:
                                    gxyfj.check(R.id.gxyfj3);
                                    break;
                                case 4:
                                    gxyfj.check(R.id.gxyfj4);
                                    break;
                                case 5:
                                    gxyfj.check(R.id.gxyfj5);
                                    break;
                                case 6:
                                    gxyfj.check(R.id.gxyfj6);
                                    break;
                            }
                        }

                        xl.setText(j.getString("XL"));
                    } else {
                        obj = JSON.parseObject(ret.getRd(), GxyHzsf.class);
                    }
                }else{
                    SweetAlertDialogUtil.ErrorDialogNoFinish(con, "错误提示", ret.getInfo(), "确定");
                }
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                obj = new GxyHzsf();
            }
        });
    }


    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "edit")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "gxysf")
                        .putExtra("class", "gxy.class");
                startActivityForResult(intent, 119);
            }
        }
    }

    public class GxyfjChangeListener implements TextWatcher {
        /**
         * 编辑框的内容发生改变之前的回调方法
         */
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }
        /**
         * 编辑框的内容正在发生改变时的回调方法 >>用户正在输入
         * 我们可以在这里实时地 通过搜索匹配用户的输入
         */
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }
        /**
         * 编辑框的内容改变以后,用户没有继续输入时 的回调方法
         */
        @Override
        public void afterTextChanged(Editable editable) {
            String xy1Str = xy1.getText().toString();
            String xy2Str = xy2.getText().toString();
            if(!StringUtils.isEmpty(xy1Str) && !StringUtils.isEmpty(xy2Str)){
                Integer ssy = Integer.parseInt(xy1Str ),
                        szy = Integer.parseInt(xy2Str );
                int fj = 1;
                if(ssy>=180 || szy>=110){
                    fj = 6;
                }else if((ssy>=160 && ssy<=179) || (szy>=100 && szy<=109)){
                    fj =5;
                }else if((ssy>=140 && ssy<=159) || (szy>=90 && szy<=99)){
                    fj =4;
                }else if(ssy>=140 && szy<90){
                    fj = 3;
                }else if((ssy>=120 && ssy<=139) || (szy>=80 && szy<=89)){
                    fj =2;
                }else if(ssy<120 && szy<80){
                    fj = 1;
                }
                switch (fj) {
                    case 1:
                        gxyfj.check(R.id.gxyfj1);
                        break;
                    case 2:
                        gxyfj.check(R.id.gxyfj2);
                        break;
                    case 3:
                        gxyfj.check(R.id.gxyfj3);
                        break;
                    case 4:
                        gxyfj.check(R.id.gxyfj4);
                        break;
                    case 5:
                        gxyfj.check(R.id.gxyfj5);
                        break;
                    case 6:
                        gxyfj.check(R.id.gxyfj6);
                        break;
                }
                obj.setGXYFJ(fj+"");
            }
        }
    }
}
